package com.isoft.illustrationsdraw.dto;

import java.time.LocalDateTime;
import java.util.Objects;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@AllArgsConstructor
@ToString

public class CommentDTO {
    @JsonSerialize(using = ToStringSerializer.class)
    private Long commentId;

    @JsonSerialize(using = ToStringSerializer.class)
    private Long illustrationId;

    private String content;
    private LocalDateTime createdAt;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long commenterId;

    private String nickname;
    private String profileImgUrl;

    public CommentDTO(){}


       // 重写 equals 方法
       @Override
       public boolean equals(Object obj) {
           if (this == obj) {
               return true;  // 如果是同一个对象
           }
           if (obj == null || getClass() != obj.getClass()) {
               return false;  // 如果是不同类或者为 null
           }
           CommentDTO comment = (CommentDTO) obj;  // 强制转换为 Commenter 对象
           return Objects.equals(commentId, comment.getCommentId());  // 根据 id 字段判断是否相等
       }
   
       // 重写 hashCode 方法
       @Override
       public int hashCode() {
           return Objects.hash(commentId);  // 使用 id 字段计算 hashCode
       }

}
